<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        img {
            cursor: pointer;
            width: 200px;
            height: 150px;
        }
    </style>
</head>
<body>
<!-- //点击每个图片弹出对话框
//方法一： -->
<!-- <div id="img">
        <img src="../images/1.jpg" alt="">
        <img src="../images/1.jpg" alt="">
        <img src="../images/1.jpg" alt="">
        <img src="../images/1.jpg" alt="">
        <img src="../images/1.jpg" alt="">
        <img src="../images/1.jpg" alt="">
</div>
<script>

document.getElementById("img").onclick=function(){
    alert("哈哈，你好像傻子")
};
</script> -->
<img src="../images/1.jpg" alt="">
<img src="../images/1.jpg" alt="">
<img src="../images/1.jpg" alt="">
<script>
    var imgObj = document.getElementsByTagName("img");
    for (var i = 0; i < imgObj.length; i++) {
        imgObj[i].onclick = function () {
            alert("你是个傻子");
        };
    }

</script>

</body>
</html> 
